#include "MaterialViewRenderPass.h"
#include <SERender/Renderer/Renderer.h>
#include <SEngine/Render/Descriptors/SceneDescriptor.h>
#include <SECore/Ecs/Scene.h>
#include <SEngine/Ecs/Components/ModelRenderComp.h>
#include <SECore/Manager.h>

namespace SEngine
{
    
    MaterialViewRenderPass::MaterialViewRenderPass(Renderer &renderer)
        : RenderPass(renderer)
    {
    }

    void MaterialViewRenderPass::DrawFrame()
    {
        auto & sceneDes = m_renderer.AnyDescriptor::GetDescriptor<SceneDescriptor>()->get();
        auto & materialDes = m_renderer.AnyDescriptor::GetDescriptor<MaterialDescriptor>()->get();
        if (sceneDes.scene) {
            sceneDes.scene->Components<ModelRenderComp>([&](Actor & actor, ModelRenderComp & comp) {
                comp.m_model.Draw(m_renderer, materialDes.material);
            });
        }
    }

} // namespace SEngine
